package j20251009;

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            for(int i=0;i<50;i++){
                try {
                    // 等待主线程执行完毕
                    //Thread.currentThread().join();
                    System.out.println(Thread.currentThread().getName()+"我还活着");
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName()+"我要结束了");
        });
        t.start();
        // 等待t线程执行完毕
        t.join();
    }
}
